<?php if(!defined('HDPHP_PATH'))EXIT;
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."address`");
$db->exe("CREATE TABLE `".$db_prefix."address`".$db_prefix." (
  `".$db_prefix."address_id`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."consignee`".$db_prefix." varchar(60) NOT NULL DEFAULT '',
  `".$db_prefix."province`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."city`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."district`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."street`".$db_prefix." varchar(100) NOT NULL DEFAULT '',
  `".$db_prefix."zipcode`".$db_prefix." varchar(10) NOT NULL DEFAULT '',
  `".$db_prefix."telephone`".$db_prefix." varchar(20) NOT NULL DEFAULT '',
  `".$db_prefix."mobile`".$db_prefix." varchar(20) NOT NULL DEFAULT '',
  PRIMARY KEY (`".$db_prefix."address_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."admin`");
$db->exe("CREATE TABLE `".$db_prefix."admin`".$db_prefix." (
  `".$db_prefix."aid`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."username`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."password`".$db_prefix." char(32) NOT NULL DEFAULT '',
  `".$db_prefix."email`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."add_time`".$db_prefix." timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`".$db_prefix."aid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."attribute`");
$db->exe("CREATE TABLE `".$db_prefix."attribute`".$db_prefix." (
  `".$db_prefix."attr_id`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."attr_name`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."type_id`".$db_prefix." smallint(6) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."attr_input`".$db_prefix." tinyint(4) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."attr_value`".$db_prefix." text NOT NULL,
  `".$db_prefix."sort_order`".$db_prefix." tinyint(4) unsigned NOT NULL DEFAULT '50',
  PRIMARY KEY (`".$db_prefix."attr_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."brand`");
$db->exe("CREATE TABLE `".$db_prefix."brand`".$db_prefix." (
  `".$db_prefix."brand_id`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."brand_name`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."brand_desc`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."url`".$db_prefix." varchar(100) NOT NULL DEFAULT '',
  `".$db_prefix."logo`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."sort_order`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."is_show`".$db_prefix." tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`".$db_prefix."brand_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."cart`");
$db->exe("CREATE TABLE `".$db_prefix."cart`".$db_prefix." (
  `".$db_prefix."cart_id`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."user_id`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."goods_id`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."goods_name`".$db_prefix." varchar(100) NOT NULL DEFAULT '',
  `".$db_prefix."goods_img`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."goods_attr`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."goods_number`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '1',
  `".$db_prefix."goods_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  `".$db_prefix."market_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  `".$db_prefix."subtotal`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`".$db_prefix."cart_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."category`");
$db->exe("CREATE TABLE `".$db_prefix."category`".$db_prefix." (
  `".$db_prefix."cid`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."cname`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."pid`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."cdesc`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."csort`".$db_prefix." tinyint(4) NOT NULL DEFAULT '50',
  `".$db_prefix."ico`".$db_prefix." varchar(15) DEFAULT '',
  `".$db_prefix."is_show`".$db_prefix." tinyint(4) NOT NULL DEFAULT '1',
  PRIMARY KEY (`".$db_prefix."cid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=70 DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."config`");
$db->exe("CREATE TABLE `".$db_prefix."config`".$db_prefix." (
  `".$db_prefix."coid`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `".$db_prefix."name`".$db_prefix." varchar(15) NOT NULL DEFAULT '' COMMENT '配置项名称',
  `".$db_prefix."value`".$db_prefix." varchar(70) NOT NULL DEFAULT '' COMMENT '配置值',
  `".$db_prefix."title`".$db_prefix." varchar(45) NOT NULL DEFAULT '' COMMENT '配置项标题',
  `".$db_prefix."des`".$db_prefix." varchar(255) NOT NULL DEFAULT '' COMMENT '配置项详细描述',
  `".$db_prefix."type_id`".$db_prefix." tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '配置项类型id，相同类型id相同',
  PRIMARY KEY (`".$db_prefix."coid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=25 DEFAULT CHARSET=utf8 COMMENT='站点配置'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."flink`");
$db->exe("CREATE TABLE `".$db_prefix."flink`".$db_prefix." (
  `".$db_prefix."fid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '友情链接主键id',
  `".$db_prefix."fname`".$db_prefix." varchar(30) NOT NULL DEFAULT '' COMMENT '友情链接名称',
  `".$db_prefix."msg`".$db_prefix." varchar(150) NOT NULL DEFAULT '' COMMENT '友情链接描述',
  `".$db_prefix."addtime`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
  `".$db_prefix."sort`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '100' COMMENT '排序',
  `".$db_prefix."logo`".$db_prefix." varchar(80) NOT NULL DEFAULT '' COMMENT '友情链接Logo',
  `".$db_prefix."url`".$db_prefix." varchar(75) NOT NULL DEFAULT '' COMMENT '友情链接地址',
  `".$db_prefix."is_show`".$db_prefix." tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '0为不显示，1为默认为显示',
  PRIMARY KEY (`".$db_prefix."fid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COMMENT='友情链接'");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."galary`");
$db->exe("CREATE TABLE `".$db_prefix."galary`".$db_prefix." (
  `".$db_prefix."img_id`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."goods_id`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."img_url`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."thumb_url`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."img_desc`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`".$db_prefix."img_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods`");
$db->exe("CREATE TABLE `".$db_prefix."goods`".$db_prefix." (
  `".$db_prefix."goods_id`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."goods_sn`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."goods_name`".$db_prefix." varchar(100) NOT NULL DEFAULT '',
  `".$db_prefix."goods_brief`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."goods_desc`".$db_prefix." text NOT NULL,
  `".$db_prefix."cat_id`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."market_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  `".$db_prefix."shop_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  `".$db_prefix."promote_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  `".$db_prefix."promote_start_time`".$db_prefix." int(10) NOT NULL DEFAULT '0',
  `".$db_prefix."promote_end_time`".$db_prefix." int(10) NOT NULL DEFAULT '0',
  `".$db_prefix."goods_img`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."goods_thumb`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."goods_number`".$db_prefix." smallint(5) NOT NULL DEFAULT '0',
  `".$db_prefix."click_count`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."type_id`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."is_promote`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."is_hot`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."is_onsale`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '1',
  `".$db_prefix."add_time`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`".$db_prefix."goods_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods_attr`");
$db->exe("CREATE TABLE `".$db_prefix."goods_attr`".$db_prefix." (
  `".$db_prefix."goods_attr_id`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."goods_id`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."attr_value`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."attr_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`".$db_prefix."goods_attr_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."goods_type`");
$db->exe("CREATE TABLE `".$db_prefix."goods_type`".$db_prefix." (
  `".$db_prefix."type_id`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."type_name`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`".$db_prefix."type_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."order_goods`");
$db->exe("CREATE TABLE `".$db_prefix."order_goods`".$db_prefix." (
  `".$db_prefix."rec_id`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."order_id`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."goods_id`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."goods_name`".$db_prefix." varchar(100) NOT NULL DEFAULT '',
  `".$db_prefix."goods_img`".$db_prefix." varchar(50) NOT NULL DEFAULT '',
  `".$db_prefix."shop_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  `".$db_prefix."goods_price`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  `".$db_prefix."goods_number`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '1',
  `".$db_prefix."goods_attr`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."subtotal`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`".$db_prefix."rec_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."payment`");
$db->exe("CREATE TABLE `".$db_prefix."payment`".$db_prefix." (
  `".$db_prefix."pay_id`".$db_prefix." tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."pay_name`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."pay_desc`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."enabled`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`".$db_prefix."pay_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."regin`");
$db->exe("CREATE TABLE `".$db_prefix."regin`".$db_prefix." (
  `".$db_prefix."regin_id`".$db_prefix." smallint(5) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."parent_id`".$db_prefix." smallint(5) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."region_name`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."region_type`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`".$db_prefix."regin_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."shipping`");
$db->exe("CREATE TABLE `".$db_prefix."shipping`".$db_prefix." (
  `".$db_prefix."shipping_id`".$db_prefix." tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."shipping_name`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."shipping_desc`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."shipping_fee`".$db_prefix." decimal(10,2) NOT NULL DEFAULT '0.00',
  `".$db_prefix."enabled`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`".$db_prefix."shipping_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."shop_order`");
$db->exe("CREATE TABLE `".$db_prefix."shop_order`".$db_prefix." (
  `".$db_prefix."order_id`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."order_sn`".$db_prefix." varchar(30) NOT NULL DEFAULT '',
  `".$db_prefix."user_id`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."address_id`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."order_status`".$db_prefix." tinyint(3) unsigned NOT NULL DEFAULT '0',
  `".$db_prefix."postscripts`".$db_prefix." varchar(255) NOT NULL DEFAULT '',
  `".$db_prefix."shipping_id`".$db_prefix." tinyint(4) NOT NULL DEFAULT '0',
  `".$db_prefix."pay_id`".$db_prefix." tinyint(4) NOT NULL DEFAULT '0',
  `".$db_prefix."goods_amount`".$db_prefix." decimal(10,2) DEFAULT '0.00',
  `".$db_prefix."order_amount`".$db_prefix." decimal(10,2) DEFAULT '0.00',
  `".$db_prefix."oredr_time`".$db_prefix." int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`".$db_prefix."order_id`".$db_prefix.")
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
$db->exe("DROP TABLE IF EXISTS `".$db_prefix."user`");
$db->exe("CREATE TABLE `".$db_prefix."user`".$db_prefix." (
  `".$db_prefix."uid`".$db_prefix." int(10) unsigned NOT NULL AUTO_INCREMENT,
  `".$db_prefix."username`".$db_prefix." char(50) NOT NULL DEFAULT '',
  `".$db_prefix."pwd`".$db_prefix." char(32) NOT NULL DEFAULT '',
  `".$db_prefix."tel`".$db_prefix." char(11) NOT NULL,
  `".$db_prefix."reg_time`".$db_prefix." int(11) DEFAULT NULL,
  PRIMARY KEY (`".$db_prefix."uid`".$db_prefix.")
) ENGINE=MyISAM AUTO_INCREMENT=99 DEFAULT CHARSET=utf8");
